import { createStore } from "vuex";
const store = createStore({
  state: {
	  userInfo: {},
	  hasLogin: false
  },
  mutations: {
  	login(state, provider) {
  		state.hasLogin = true
  		state.userInfo.token = provider.token
  		state.userInfo.username = provider.username
  		state.userInfo.id = provider.id
  		state.userInfo.head_img = provider.head_img
  		uni.setStorage({
  			key: 'userInfo',
  			data: state.userInfo
  		})
  	},
  	logout(state) {
  		state.hasLogin = false
  		state.userInfo = {}
  		uni.removeStorage({
  			key: 'userInfo'
  		});
  	}
  }
});
export default store;